package cn.singletion;

/**
 * 懒汉式 
 * 优点 延迟加载
 * 问题 线程不安全 synchronized
 * @author Administrator
 *
 */
public class SingBean2 {

	//1 私有构造方法
	private SingBean2(){}
	
	//2 提供私有静态实例 类加载不创建
	private static SingBean2 singBean;
	
	//3 共有方法返回该实例
	public synchronized static SingBean2 getInstance(){
		if(singBean == null){
			//延迟加载 调用方法时创建
			singBean = new SingBean2();
		}
		return singBean;
	}
}
